<?php
// 命令模式 行为模式 事务模式
// 

class Receiver {public function action() {}}

abstract class Command
{
	protected $receiver;
	function __construct(Receiver $receiver)
	{
		$this->receiver = $receiver;
	}
	abstract public function execute();
}

class MyCommand extends Command
{
	function __construct(Receiver $receiver)
	{
		parent::__construct($receiver);
	}

	public function execute()
	{
		$this->receiver->action();
	}
}

class Invoker
{
	protected $command;

	function __construct(Command $command)
	{
		$this->command = $command;
	}

	public function invoke()
	{
		$this->command->execute();
	}
}

$receiver = new Receiver;
$command = new MyCommand($receiver);
$invoker = new Invoker($command);
$invoker->invoke();